package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(150); not null; commit:'用户名'"`
	Password string `gorm:"type:char(32); not null; commit:'密码'"`
	Phone    string `gorm:"type:char(11); not null; commit:'手机号'"`
	Status   int64  `gorm:"type:int; not null; default:0;commit:'用户状态: 0-正常,1-异常'"`
}

func (u *User) GetUsername(db *gorm.DB, username string) error {
	err := db.Where("username=?", username).Find(&u).Error
	return err
}
func (u *User) CreateUser(db *gorm.DB) error {
	err := db.Create(&u).Error
	return err
}
